package com.mycat.dfs;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.csource.common.MyException;

import com.mycat.common.util.PropertyHelper;
import com.mycat.dfs.server.impl.FastDFSUtils;

/**
 * FastDFS测试
 *
 * @author Roger
 */
public class FastDFSMain {

    @SuppressWarnings("resource")
    public static void main(String[] args) {

        FastDFSUtils dfs = new FastDFSUtils();
        dfs.setAnti_steal_token(Boolean.getBoolean(PropertyHelper.get("fastdfs.anti_steal_token")));
        dfs.setCharset(PropertyHelper.get("fastdfs.charset"));
        dfs.setConnect_timeout(Integer.parseInt(PropertyHelper.get("fastdfs.connect_timeout")));
        dfs.setNetwork_timeout(Integer.parseInt(PropertyHelper.get("fastdfs.network_timeout")));
        dfs.setSecret_key(PropertyHelper.get("fastdfs.secet_key"));
        dfs.setTracker_http_port(Integer.parseInt(PropertyHelper.get("fastdfs.tracker_http_port")));
        dfs.setTracker_server_ip(PropertyHelper.get("fastdfs.tracker_server_ip"));
        dfs.setTracker_server_port(Integer.parseInt(PropertyHelper.get("fastdfs.tracker_server_port")));

        File file = new File("D:\\upload\\14761776714301.jpg");
        InputStream input;
        try {
//            dfs.init();
//            input = new FileInputStream(file);
//            FileInputStream fi = new FileInputStream(file);
//
//
//            String name = dfs.uploadFile(input, "jpg");
//            System.out.println("http://fs.yunzhitx.com:8888/"+name);



//            ExecutorService executor = Executors.newFixedThreadPool(2);
//
//            executor.execute(new Thread(new UploadThread()));

            for (int i = 0;i<50;i++){
                new Thread(new UploadThread()).start();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
